package com.cj.library.widget.utiles;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by Administrator on 2016-06-20.
 */
public class ToastUtile {
    private static Toast toast;

    public static void show(Context ctx,String msg){
        show(ctx,msg,Toast.LENGTH_LONG);
    }

    public static void show(Context ctx,String msg,int duration){
        if(toast == null){
            toast = Toast.makeText(ctx.getApplicationContext(),msg,duration);
        }else{
            toast.setText(msg);
            toast.setDuration(duration);
        }
        toast.show();
    }

    public static void cancel(){
        if(toast != null){
            toast.cancel();
        }
    }
}
